package uniandes.cupi2.musiteka.servidor.interfaz;

import javax.swing.JPanel;
import java.awt.Frame;
import java.awt.BorderLayout;
import javax.swing.JDialog;
import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.GridBagLayout;
import javax.swing.BorderFactory;
import javax.swing.border.TitledBorder;
import java.awt.Font;
import java.awt.Color;
import java.util.ArrayList;

import javax.swing.JComboBox;
import javax.swing.JButton;
import javax.swing.JScrollPane;
import javax.swing.JList;

import uniandes.cupi2.musiteka.servidor.mundo.IMusiteka;
import uniandes.cupi2.musiteka.servidor.mundo.musiteka1.IteradorMusiteka1;
import uniandes.cupi2.musiteka.servidor.mundo.musiteka1.Musiteka;

public class CancionesGenero extends JDialog {

	private static final long serialVersionUID = 1L;

	private JPanel jContentPane = null;

	private JPanel jPanelGeneros = null;

	private JComboBox jComboBoxGeneros = null;

	private JPanel jPanelbotones = null;

	private JButton jButtonVer = null;

	private JButton jButtonCancelar = null;

	private JScrollPane jScrollPaneCancionesGenero = null;

	private JList jListCancionesGenero = null;

	public Musiteka mundo=null;
	/**
	 * @param owner
	 */
	public CancionesGenero(IMusiteka nMundo) {
		mundo=(Musiteka) nMundo;
		super.setVisible(true);
		initialize();
	}

	public CancionesGenero() {
		super.setVisible(true);
		initialize();
		// TODO Auto-generated constructor stub
	}

	/**
	 * This method initializes this
	 * 
	 * @return void
	 */
	private void initialize() {
		this.setSize(301, 465);
		this.setTitle("Canciones por genero");
		this.setContentPane(getJContentPane());
	}

	/**
	 * This method initializes jContentPane
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getJContentPane() {
		if (jContentPane == null) {
			jContentPane = new JPanel();
			jContentPane.setLayout(null);
			jContentPane.add(getJPanelGeneros(), null);
			jContentPane.add(getJPanelbotones(), null);
			jContentPane.add(getJScrollPaneCancionesGenero(), null);
		}
		return jContentPane;
	}

	/**
	 * This method initializes jPanelGeneros	
	 * 	
	 * @return javax.swing.JPanel	
	 */
	private JPanel getJPanelGeneros() {
		if (jPanelGeneros == null) {
			jPanelGeneros = new JPanel();
			jPanelGeneros.setLayout(null);
			jPanelGeneros.setBounds(new Rectangle(15, 225, 256, 91));
			jPanelGeneros.setBorder(BorderFactory.createTitledBorder(null, "Genero", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Dialog", Font.BOLD, 12), new Color(51, 51, 51)));
			jPanelGeneros.add(getJComboBoxGeneros(), null);
		}
		return jPanelGeneros;
	}

	/**
	 * This method initializes jComboBoxGeneros	
	 * 	
	 * @return javax.swing.JComboBox	
	 */
	private JComboBox getJComboBoxGeneros() {
		if (jComboBoxGeneros == null) {
			jComboBoxGeneros = new JComboBox();
			jComboBoxGeneros.setBounds(new Rectangle(30, 30, 196, 37));
			jComboBoxGeneros.addItem("Jazz");
			jComboBoxGeneros.addItem("World");
			jComboBoxGeneros.addItem("Electronical & Dance");
			jComboBoxGeneros.addItem("Rock");
			jComboBoxGeneros.addItem("Latin");
			jComboBoxGeneros.addItem("Clasica");
		}
		return jComboBoxGeneros;
	}

	/**
	 * This method initializes jPanelbotones	
	 * 	
	 * @return javax.swing.JPanel	
	 */
	private JPanel getJPanelbotones() {
		if (jPanelbotones == null) {
			jPanelbotones = new JPanel();
			jPanelbotones.setLayout(null);
			jPanelbotones.setBounds(new Rectangle(15, 330, 256, 82));
			jPanelbotones.setBorder(BorderFactory.createTitledBorder(null, "", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Dialog", Font.BOLD, 12), new Color(51, 51, 51)));
			jPanelbotones.add(getJButtonVer(), null);
			jPanelbotones.add(getJButtonCancelar(), null);
		}
		return jPanelbotones;
	}

	/**
	 * This method initializes jButtonVer	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getJButtonVer() {
		if (jButtonVer == null) {
			jButtonVer = new JButton();
			jButtonVer.setBounds(new Rectangle(15, 30, 95, 34));
			jButtonVer.setText("Ver");
			jButtonVer.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					String nGenero=(String) jComboBoxGeneros.getSelectedItem();
					ArrayList<String> lista=new ArrayList();
					IteradorMusiteka1 aux=(IteradorMusiteka1) mundo.mostrarCancionesPorGenero(nGenero);
					while(aux.haySiguiente())
					{
						lista.add(aux.darSiguiente().toString());
					}
					jListCancionesGenero.setListData(lista.toArray());
					
				
					
				}
			});
		}
		return jButtonVer;
	}

	/**
	 * This method initializes jButtonCancelar	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getJButtonCancelar() {
		if (jButtonCancelar == null) {
			jButtonCancelar = new JButton();
			jButtonCancelar.setBounds(new Rectangle(150, 30, 91, 31));
			jButtonCancelar.setText("Cancelar");
			jButtonCancelar.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					dispose();
					System.out.println("actionPerformed()"); // TODO Auto-generated Event stub actionPerformed()
				}
			});
			jButtonCancelar.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					dispose();
				}
			});
		}
		return jButtonCancelar;
	}

	/**
	 * This method initializes jScrollPaneCancionesGenero	
	 * 	
	 * @return javax.swing.JScrollPane	
	 */
	private JScrollPane getJScrollPaneCancionesGenero() {
		if (jScrollPaneCancionesGenero == null) {
			jScrollPaneCancionesGenero = new JScrollPane();
			jScrollPaneCancionesGenero.setBounds(new Rectangle(16, 0, 255, 211));
			jScrollPaneCancionesGenero.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
			jScrollPaneCancionesGenero.setBorder(BorderFactory.createTitledBorder(null, "Canciones del genero", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Dialog", Font.BOLD, 12), new Color(51, 51, 51)));
			jScrollPaneCancionesGenero.setViewportView(getJListCancionesGenero());
		}
		return jScrollPaneCancionesGenero;
	}

	/**
	 * This method initializes jListCancionesGenero	
	 * 	
	 * @return javax.swing.JList	
	 */
	private JList getJListCancionesGenero() {
		if (jListCancionesGenero == null) {
			jListCancionesGenero = new JList();
		}
		return jListCancionesGenero;
	}

}  //  @jve:decl-index=0:visual-constraint="10,10"
